package cn.anecansaitin.whimsy.client.listener;

import cn.anecansaitin.whimsy.Whimsy;
import cn.anecansaitin.whimsy.common.capabilities.battle.IBattleMode;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.ComputeFovModifierEvent;

@Mod.EventBusSubscriber(modid = Whimsy.MODID, value = Dist.CLIENT)
public class OnFovModify {
    @SubscribeEvent
    public static void fov(ComputeFovModifierEvent event) {
        LocalPlayer player = Minecraft.getInstance().player;

        if (player == null) {
            return;
        }

        IBattleMode battleMode = player.getCapability(IBattleMode.BATTLE_MODE);

        if (battleMode == null) {
            return;
        }

        //在战斗模式下，修改FOV始终为1
        if (battleMode.isInMode()) {
            event.setNewFovModifier(1);
        }
    }
}
